package com.example.a22310.myapplication.Beans;


import android.databinding.BaseObservable;
import android.databinding.BindingAdapter;
import android.view.View;
import android.widget.ImageView;

import com.squareup.picasso.Picasso;

import java.io.Serializable;
import java.util.List;

import static com.example.a22310.myapplication.GloableClass.Yuejian.IMG_URL;

public class Order {


    /**
     * code : 200
     * orderlist : [{"order_id":"1","userid":"1","clubid":"1","number":"5","name":"长剑","pic":"xc.jpg","price":"99.9","data":"2016-09-12","status":"1"},{"order_id":"2","userid":"1","clubid":"2","number":"3","name":"战马","pic":"xh.jpg","price":"9.9","data":"2016-09-12","status":"1"}]
     */

    private int code;
    private List<OrderlistBean> orderlist;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public List<OrderlistBean> getOrderlist() {
        return orderlist;
    }

    public void setOrderlist(List<OrderlistBean> orderlist) {
        this.orderlist = orderlist;
    }

    public static class OrderlistBean extends BaseObservable implements Serializable {
        /**
         * order_id : 1
         * userid : 1
         * clubid : 1
         * number : 5
         * name : 长剑
         * pic : xc.jpg
         * price : 99.9
         * data : 2016-09-12
         * status : 1
         */

        private String order_id;
        private String userid;
        private String clubid;
        private String number;
        private String name;
        private String pic;
        private String price;
        private String data;
        private String status;



        public OrderlistBean()
        {

        }







        public OrderlistBean(String order_id,  String userid, String clubid, String number,
                             String name, String pic,String price,String  data,String status)
        {
            this.order_id = order_id;
            this.userid = userid;
            this.clubid=clubid;
            this.number =number;
            this.name = name;
            this.pic = pic;
            this.price=price;
            this.data=data;
            this.status =status;
        }
        @BindingAdapter("pic")
        public static void loadInternetImage(ImageView iv, String pic) {
            pic = IMG_URL+pic;
            Picasso.with(iv.getContext()).load(pic).into(iv);
        }

        @Override
        public String toString() {


            return "OrderlistBean{" +
                    "order_id='" + order_id + '\'' +
                    ", userid='" + userid + '\'' +
                    ", clubid='" + clubid + '\'' +
                    "number='" + number + '\'' +
                    ", name='" + name + '\'' +
                    ", pic='" + pic + '\'' +
                    "price='" + price + '\'' +
                    "data='" + data + '\'' +
                    ", status='" + status + '\'' +
                    '}';
        }

        public void onItemClick(View view){
//         Intent intent=new Intent(view.getContext(),OrderDetail.class);

            OrderlistBean orderlistBean = new  OrderlistBean();
            orderlistBean.setOrder_id(getOrder_id());
            orderlistBean.setUserid(getUserid());
            orderlistBean.setClubid(getClubid());
            orderlistBean.setName(getName());
            orderlistBean.setPic(getPic());
            orderlistBean.setPrice(getPrice());
            orderlistBean.setData(getData());
            orderlistBean.setStatus(getStatus());
//                intent.putExtra("Order", OrderlistBean);
//                view.getContext().startActivity(intent);
        }



        public String getOrder_id() {
            return order_id;
        }

        public void setOrder_id(String order_id) {
            this.order_id = order_id;
        }

        public String getUserid() {
            return userid;
        }

        public void setUserid(String userid) {
            this.userid = userid;
        }

        public String getClubid() {
            return clubid;
        }

        public void setClubid(String clubid) {
            this.clubid = clubid;
        }

        public String getNumber() {
            return number;
        }

        public void setNumber(String number) {
            this.number = number;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getPic() {
            return IMG_URL+pic;
        }

        public void setPic(String pic) {
            this.pic = pic;
        }

        public String getPrice() {
            return "￥"+price;
        }

        public void setPrice(String price) {
            this.price = price;
        }

        public String getData() {
            return data;
        }

        public void setData(String data) {
            this.data = data;
        }

        public String getStatus() {
            return status;
        }

        public void setStatus(String status) {
            this.status = status;
        }
    }



}

